/**
 * 生产环境切换主题方式,加载对应主题的css文件
 *
 * @author chenhuachun
 *
 */

let linkEl = null
module.exports = function (key, app) {
  // const themes = (app ? window.__MY_APP_THEMES__ : window.__MY_THEMES__) || {}
  const themes = window.__MY_THEMES__ || {}
  const theme = themes[key]
  if (theme) {
    if (!linkEl) {
      linkEl = document.createElement('link')
      linkEl.rel = 'stylesheet'
      document.body.appendChild(linkEl)
    }
    linkEl.href = theme
  } else {
    if (linkEl) {
      linkEl.parentNode.removeChild(linkEl)
      linkEl = null
    }
  }
  
}
